package thread;

/**
 * Creared with IntelliJ IDEA.
 * Description:
 * User:yxd
 * Date:2022-03-20
 * Time:22:53
 */
//另一种创建线程的方法 实现runnable接口
class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("hello thread");
    }
}
public class Demo2 {
    public static void main(String[] args) {
        Thread t = new Thread(new MyThread2());//Thread的构造方法  通过Runnable来描述任务的内容进一步再把描述好的任务交给Thread实例
        t.start();
    }
}
